package com.iaiai.cobra.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iaiai.cobra.common.vo.ResultVo;
import com.iaiai.cobra.core.BaseController;
import com.iaiai.cobra.redis.bean.CacheOnline;
import com.iaiai.cobra.web.params.PageParams;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * Created with OnlineController.
 * Package: com.iaiai.cobra.system.controller
 * Author: iaiai
 * Create Time: 2024/7/31 21:48
 * QQ: 176291935
 * Email: 176291935@qq.com
 * Description: 在线用户
 */
@RestController
@RequestMapping("/online")
public class OnlineController extends BaseController {

    @PostMapping("/list.json")
    public ResultVo list(@RequestBody PageParams params) throws IOException {
        if(params==null)new PageParams();
        if(params.getPage()==null || params.getLimit()==null){
            return fail("参数异常");
        }

        Page<CacheOnline> page = serviceManager.redisOnlineCache.findKeysForPage(params.getPage(),params.getLimit());
        return success(page);
    }

}
